<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:pe="http://primefaces.org/ui/extensions">

<h:head>
	<link rel="stylesheet" type="text/css" href="../../css/style.css"
		media="screen" />
	<meta http-equiv="refresh"
		content="#{session.maxInactiveInterval};url=map12.xhtml?faces-redirect=true" />
</h:head>
<h:body style="margin:0px;">
	<div class="space"></div>
	#{reportBean.setManageInventory('')}
#{reportBean.setManageInternalUse('')}
#{reportBean.setManageMaps('border: 1px solid blue;')}
#{reportBean.setManageUtility('')}
	<h:outputScript library="javascript" name="mapExter.js" target="head" />
	<h:form id="form-dialog-move">
		<p:dialog header="Muovi Item" id="modalMoveItem" visible="false"
			widgetVar="modalMoveItem" modal="true" closable="true"
			draggable="false" resizable="false">
			<p:panelGrid columns="2">
				<h:outputText value="Persona:" />
				<p:selectOneMenu value="#{itemBean.owner}" filter="true"
					filterMatchMode="contains" converter="personconverter">
					<f:selectItem itemLabel="Seleziona" itemValue="" />
					<f:selectItems value="#{tableBeanItem.avaliableOwner}" var="ownerM"
						itemLabel="#{ownerM.name} #{ownerM.surname}" itemValue="#{ownerM}" />
				</p:selectOneMenu>
				<h:outputText value="Ufficio:" />
				<p:selectOneMenu value="#{itemBean.office}" filter="true"
					filterMatchMode="contains" converter="officeconverter">
					<f:selectItem itemLabel="Seleziona" itemValue="" />
					<f:selectItems value="#{tableBeanItem.avaliableOffice}"
						var="officeM" itemLabel="#{officeM.name}" itemValue="#{officeM}" />
				</p:selectOneMenu>
				<f:facet name="footer">
					<center>
						<p:commandButton value="Muovi"
							actionListener="#{tableBeanItem.onMove}"
							update=":form-table:itemReportTable"
							onclick="modalMoveItem.hide()"
							oncomplete="itemReportTable.filter()" />
						<p:commandButton value="Annulla" onclick="modalMoveItem.hide();"
							type="button" update="modalMoveItem" />
					</center>
				</f:facet>
			</p:panelGrid>
		</p:dialog>
	</h:form>
	<h:form id="form-dialog-insert">
		<p:dialog header="Inserisci Item" id="modalInsertItem" visible="false"
			widgetVar="modalInsertItem" modal="true" closable="true"
			draggable="false" resizable="false">
			<p:panelGrid columns="2">
				<h:outputText value="Item:" />
				<p:selectOneMenu value="#{itemBean.internalItem}" filter="true"
					filterMatchMode="contains" converter="itemconverter" itemLabel="#{item.barcode.barcode} - #{item.description}"
					var="itemdialog" styleClass="custom-item-combobox">
					<f:selectItem itemLabel="Seleziona" itemValue="" />
					<f:selectItems value="#{tableBeanItem.avaliableItem}" var="item"
						itemValue="#{item}" />

					<p:column headerText="Barcode">#{itemdialog.barcode.barcode}</p:column>
					<p:column headerText="Descrizione">#{itemdialog.description}</p:column>
					<p:column headerText="Brand">#{itemdialog.brand}</p:column>
					<p:ajax event="change" update="itemdialogquantity" />
				</p:selectOneMenu>
				<h:outputText value="Quantita:" />
				<pe:inputNumber value="#{itemBean.quantity}" decimalPlaces="0"
					maxValue="99" minValue="1"
					disabled="#{itemBean.internalItem.kind.net_reachable}"
					id="itemdialogquantity" />
				<h:outputText value="Persona:" />
				<p:selectOneMenu value="#{itemBean.owner}" filter="true"
					filterMatchMode="contains" converter="personconverter">
					<f:selectItem itemLabel="Seleziona" itemValue="" />
					<f:selectItems value="#{tableBeanItem.avaliableOwner}" var="owner"
						itemLabel="#{owner.name} #{owner.surname}" itemValue="#{owner}" />
				</p:selectOneMenu>
				<f:facet name="footer">
					<center>
						<p:commandButton value="Salva"
							actionListener="#{tableBeanItem.onCreate}" type="submit"
							update=":form-table:itemReportTable"
							oncomplete="modalInsertItem.hide();" />
						<p:commandButton value="Annulla"
							onclick="itemReportTable.filter();modalInsertItem.hide();"
							type="button" update="modalInsertItem" />
					</center>
				</f:facet>
			</p:panelGrid>
		</p:dialog>
	</h:form>
	<h:form id="form-dialog">
		<p:dialog id="modalDialog" visible="false" widgetVar="dialogModal"
			modal="true" closable="false" draggable="false" resizable="false">
			<p:ajaxStatus onstart="dialogModal.show()"
				oncomplete="dialogModal.hide()" />
			<p:graphicImage value="../../images/loading.gif" />
		</p:dialog>

		<p:dialog header="Componenti Pc" id="modalViewComponent"
			visible="false" widgetVar="modalViewComponent" modal="true"
			closable="true" draggable="false" resizable="false">
			<p:dataTable var="comp"
				value="#{tableBeanItem.itemGet.componentList}" scrollable="true"
				scrollHeight="200">
				<p:column headerText="Tipo" width="80">
					<h:outputText value="#{comp.name}" />
				</p:column>

				<p:column headerText="Valore" width="200">
					<h:outputText value="#{comp.details}" />
				</p:column>
			</p:dataTable>
		</p:dialog>


		<p:confirmDialog id="confirmDialog" message="Sei sicuro ?"
			header="Cancellazione Oggetto" severity="alert"
			widgetVar="confirmation">

			<p:commandButton id="confirm" value="Si"
				update=":form-table:itemReportTable"
				oncomplete="itemReportTable.filter(),confirmation.hide()"
				actionListener="#{tableBeanItem.onRemove}" />
			<p:commandButton id="decline" value="No"
				onclick="confirmation.hide()" type="button" />

		</p:confirmDialog>


	</h:form>
	<ui:include src="../common/menu.xhtml" />
	<p:layout fullPage="true">
		<p:ajax event="resize" update=":form-table" />
		<p:layoutUnit position="north" styleClass="layoutUnit-north">

		</p:layoutUnit>
		<p:layoutUnit position="center" styleClass="layoutUnit-center">
			<h:form id="form-control">
				<center>
					<div class="scribblar" id="divMap">
						<p:media value="../../flash/map12.swf" id="moveFlash" width="100%"
							height="100%" player="flash">
							<f:param name="autoPlay" value="true" />
							<f:param name="wmode" value="transparent" />
						</p:media>
					</div>
				</center>
				<p:inputText value="#{reportBean.selectedOffice}" id="officetext"
					widgetVar="officevar" style="display:none;" />
				<p:commandButton value="ok" id="goToOfficeButton"
					action="#{reportBean.filterItemByMap}"
					update=":form-table:itemReportTable" style="display:none;" />

			</h:form>
			<h:form id="form-table">
				<p:growl id="messages" showDetail="true" life="2000" />

				<p:remoteCommand id="load_component" name="load_component"
					oncomplete="modalViewComponent.show()"
					actionListener="#{tableBeanItem.populateComponent}"
					update=":form-dialog:modalViewComponent" />

				<p:dataTable var="item" value="#{tableBeanItem.tableList}"
					widgetVar="itemReportTable" id="itemReportTable" editable="true"
					additionalScrollHeight="300" resizableColumns="true"
					scrollable="true" scrollHeight="0" scrollRows="20" emptyMessage="Nessun Item con Questo Criterio"
					styleClass="item-table" liveScroll="true">

					<p:ajax event="rowEdit" update="@this,:form-table:messages"
						listener="#{tableBeanItem.onEdit}" immediate="true" />

					<p:ajax event="rowEditCancel" update="@this,:form-table:messages"
						listener="#{tableBeanItem.onCancel}" immediate="true" />


					<p:column headerText="Options" width="100">
						<div class="div-tool-button">
							<p:commandLink id="rowEditLink"
								actionListener="#{tableBeanItem.onStartEdit}" ajax="true">
								<f:attribute name="parameter" value="#{item}" />
								<p:rowEditor />
							</p:commandLink>
							<p:commandButton id="submit_erase"
								oncomplete="confirmation.show()"
								actionListener="#{tableBeanItem.onSetItem}" icon="ui-icon-trash"
								styleClass="custom-trash">
								<f:attribute name="parameter" value="#{item}" />
							</p:commandButton>
							<p:commandButton id="submit_move" icon="ui-icon-shuffle"
								styleClass="custom-shuffle"
								actionListener="#{tableBeanItem.onSetItem}"
								oncomplete="modalMoveItem.show();">
								<f:attribute name="parameter" value="#{item}" />
							</p:commandButton>
							<p:rowToggler rendered="#{item.kind.net_reachable}" />
							<p:commandButton id="submit_details" icon="ui-icon-contact"
								process="@this" styleClass="custom-contact"
								onstart="load_component()" rendered="#{item.net_discovered}">
								<f:setPropertyActionListener value="#{item}"
									target="#{tableBeanItem.itemGet}" />
							</p:commandButton>
						</div>
					</p:column>

					<p:column headerText="BARCODE" id="barcode" width="200"
						sortBy="#{item.barcode.barcode}"
						filterBy="#{item.barcode.barcode}" filterMatchMode="contains">
						<p:cellEditor>
							<f:facet name="output">
								<p:graphicImage
									value="../../images/barcodes/#{item.barcode.barcode}.png"
									styleClass="barcode-img" />
								<h:outputText value="#{item.barcode.description}" />

							</f:facet>
							<f:facet name="input">
								<p:graphicImage
									value="../../images/barcodes/#{item.barcode.barcode}.png"
									styleClass="barcode-img" />
								<h:outputText value="#{item.barcode.description}" />
							</f:facet>
						</p:cellEditor>
					</p:column>

					<p:column headerText="DESCRIZIONE" sortBy="#{item.description}"
						filterBy="#{item.description}" filterMatchMode="contains"
						id="description" width="150">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{item.description}" />
							</f:facet>
							<f:facet name="input">
								<h:inputText value="#{item.description}" />
							</f:facet>
						</p:cellEditor>
					</p:column>

					<p:column headerText="BRAND" sortBy="#{item.brand}" id="brand"
						width="80">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{item.brand}" />
							</f:facet>
							<f:facet name="input">
								<h:inputText value="#{item.brand}" />
							</f:facet>
						</p:cellEditor>
					</p:column>

					<p:column headerText="QUANTITA" sortBy="#{item.quantity}"
						id="quantity" width="80">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{item.quantity}" />
							</f:facet>
							<f:facet name="input">
								<pe:inputNumber value="#{item.quantity}"
									disabled="#{item.kind.net_reachable}" decimalPlaces="0"
									styleClass="quantity-field" />
							</f:facet>
						</p:cellEditor>
					</p:column>

					<p:column headerText="PERSONA" id="persona" width="200"
						filterMatchMode="contains"
						sortBy="#{item.owner.name} #{item.owner.surname}"
						filterBy="#{item.owner.name} #{item.owner.surname}">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{item.owner.name} #{item.owner.surname}" />
							</f:facet>
							<f:facet name="input">
								<p:selectOneMenu value="#{item.owner}" filter="true"
									filterMatchMode="contains" converter="personconverter">
									<f:selectItems value="#{tableBeanItem.avaliableOwner}"
										var="owner" itemLabel="#{owner.name} #{owner.surname}"
										itemValue="#{owner}" />
								</p:selectOneMenu>
							</f:facet>
						</p:cellEditor>
					</p:column>


					<p:column headerText="TIPOLOGIA" id="kind" width="220"
						filterMatchMode="contains" sortBy="#{item.kind.name}"
						filterBy="#{item.kind.name}">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{item.kind.name}" />
							</f:facet>
							<f:facet name="input">
								<h:outputText value="#{item.kind.name}" />
							</f:facet>
						</p:cellEditor>
					</p:column>

					<p:column headerText="UFFICIO" id="office" width="220"
						filterMatchMode="contains" sortBy="#{item.office.name}"
						filterBy="#{item.office.name}">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{item.office.name}" />
							</f:facet>
							<f:facet name="input">
								<p:selectOneMenu value="#{item.office}" filter="true"
									filterMatchMode="contains" converter="officeconverter">
									<f:selectItem itemLabel="Non Specificato" itemValue="" />
									<f:selectItems value="#{tableBeanItem.avaliableOffice}"
										var="office" itemLabel="#{office.name}" itemValue="#{office}" />
								</p:selectOneMenu>
							</f:facet>
						</p:cellEditor>
					</p:column>

					<f:facet name="footer">
						<div class="footer-table">
							<div class="footer-button">
								<p:commandButton id="effectsDialogButton"
									value="+ Aggiungi Item" onclick="modalInsertItem.show();"
									type="button" />
							</div>
						</div>
					</f:facet>

					<p:rowExpansion>
						<p:dataTable var="net" value="#{item.netList}" id="netReportTable"
							editable="true" resizableColumns="true" scrollHeight="0">

							<p:column id="description" width="100">
								<f:facet name="header">
									<h:outputText value="DESCRIZIONE" />
								</f:facet>
								<h:outputText value="#{net.description}" />
							</p:column>

							<p:column id="mac_address" width="100">
								<f:facet name="header">
									<h:outputText value="MAC ADDRESS" />
								</f:facet>
								<h:outputText value="#{net.mac_address}" />
							</p:column>

							<p:column id="ip_address" width="100">
								<f:facet name="header">
									<h:outputText value="IP ADDRESS" />
								</f:facet>
								<h:outputText value="#{net.ip_address}" />
							</p:column>
						</p:dataTable>

					</p:rowExpansion>

				</p:dataTable>
			</h:form>

		</p:layoutUnit>
	</p:layout>
</h:body>
</html>